<%@ page language="java" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags"%>
<%@ page isELIgnored="false"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN">
 
<html>
  <head>
    <link rel="stylesheet" href="<s:url value="/resources"/>/css/innerstyle.css" type="text/css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/cupertino/jquery-ui.custom.min.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/ui.jqgrid.css" />
    <link rel="stylesheet" type="text/css" media="screen" href="<s:url value="/resources"/>/css/ui.multiselect.css" />
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery-ui.custom.min.js"></script> 
    <script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/grid.locale-cn.js"></script>    
    <script type="text/javascript" src="<s:url value="/resources"/>/js/jquery.jqGrid.min.js"></script>
    <script type="text/javascript" src="<s:url value="/resources"/>/js/i18n/jquery.ui.datepicker-zh-CN.js"></script>
  </head>
  
  <script type="text/javascript">  
   $(function(){ 
	    $("#chax").button();
	    $("#chongz").button();    
	    $( "#datepicker" ).datepicker($.datepicker.regional[ "zh-CN" ]);
	    $( "#datepicker1" ).datepicker($.datepicker.regional[ "zh-CN" ]);
	    loadTab();    
  });
  
  //加载表
  function loadTab(){ 
      $("#myTab").jqGrid({      
		    url:'findDshtForBcxy',   
		    datatype: 'json',
		    mtype: 'post',         
		   	colNames:['操作','合同号','出卖人','买受人','数量','价格','签订日期','归档日期','toid','hetid'],
		   	colModel:[ 
		   	    {name:'caoz',index:'id',width:60,align:"center"},  		
		   		{name:'hetbh',index:'hetbh', width:150},
		   		{name:'chumdwmc',index:'chumdwmc', width:200},
		   		{name:'maisdwmc',index:'maisdwmc', width:200},
		   		{name:'shul',index:'shul', width:80},	
		   		{name:'jiag',index:'jiag', width:80},
		   		{name:'qianysj',index:'qianysj', width:120},
		   		{name:'guidsj',index:'guidsj', width:150},
		   		{name:'toid',index:'toid', width:150},
		   		{name:'hetid',index:'hetid'}
		   	],
		   
		    jsonReader: {
		           repeatitems : false, 
		           id: 'hetid'
		         },   
		    height:280, 	
		   	rowNum:10,
		   	rowList:[10,30,50],     	
		   	pager: '#pager13',
		   	rownumbers: true,   	 
		    viewrecords: true,
		    //multiselect: true, 
		    sortorder: 'desc', 
		    //caption: "模板列表",
			gridComplete:function()
				{ //在此事件中循环为每一行添加修改和删除链接 	
					var ids=$("#myTab").jqGrid('getDataIDs'); 
					//alert(ids);
					for(var j=0; j<ids.length; j++)
					{		
					     id=ids[j];		    
						 caoz="<a href='#' style='color:#f60' onclick='verify("+ id +")'>选择</a>";
						 $("#myTab").jqGrid('setRowData',id, { caoz: caoz }); 
						
					}
				}		
  });
  $("#myTab").jqGrid('hideCol',["hetid"]);
  $("#myTab").jqGrid('hideCol',["toid"]);
  }
  
	//重置
	function reset(){
	    $('#list_search  input[type=text]').val('');
		$('#list_search select').val('-1');
	 }
	
	// 查询
	function search(){ 
	  var formdata = $("#form1").serialize(); 
	  $("#myTab").jqGrid('setGridParam',{   
	                          url:'<s:url value="/htgl"/>/findDshtForBcxy?'+formdata,
							  mtype:'post',
							  page:1}).trigger("reloadGrid");  
	}	
	
	//修改
	function verify(id) { //单击修改链接的操作
	var hetxx = $("#myTab").jqGrid('getRowData',id);
	window.returnValue = hetxx;
    window.close();
	}

</script>  
<body>  
<div id="best1">
<form id="form1" method="post">
<h1>选择合同
</h1>
<table id="list_search" style="width:80%" cellpadding="0" cellspacing="0" border="0">
        <tr>
        	<td> 
            	合同号: 
            </td>
            <td>
            	<input type="text" class="longtextbox" name="aa" /> 
            </td>
           <td>
            	年份:
            </td>
            <td>
            <div class="select"><div>
            	<select name="bb" style="width:180px;">
            	 <option value="-1" selected>==请选择==</option>
	             <option value="2014">2014</option>
	             <option value="2015">2015</option>
	             
                 </select>
            </div></div>   
            </td>
            <td>
               &nbsp;
             </td>
        </tr>
        <tr>
        <td>出卖人:</td>
        <td><input type="text" class="longtextbox" name="cc" /></td>
        <td>买受人:</td>
        <td><input type="text" class="longtextbox" name="dd" /></td>
        <td algin="left">
               <input id="chax" type="button" value="查询" onclick="search();"/>&nbsp;&nbsp;&nbsp;	
               <input id="chongz" type="button" value="重置" onclick="reset();"/>
             </td>
        </tr>
  </table>
  </form>
    <table id="myTab" class="scroll" cellpadding="0" cellspacing="0"></table>  
   <div id="pager13" class="scroll"></div>  
   <div id="message" class="scroll"></div> 
</div> 
</body>
</html>
